home *** CD-ROM | disk | FTP | other *** search
Wrap
<!-- #include file="i_utils.asp" --> <% check_security(1) %> <% dim ID dim Industry dim edit_luindustry_sql dim view_luindustry_sql sub request_edit_luindustry ''' request expected input parameters for this form ID = request("ID") Industry = request("Industry") end sub sub request_view_luindustry ''' request expected input parameters for this form ID = request("ID") Industry = request("Industry") end sub sub validate_edit_luindustry ''' request and validate data entered from this form ID = trim(request("ID")) Industry = trim(request("Industry")) end sub sub validate_view_luindustry ''' request and validate data entered from this form ID = trim(request("ID")) Industry = trim(request("Industry")) end sub sub db_select_edit_luIndustry sql = "SELECT " & _ "ID, " & _ "Industry FROM luIndustry" & _ " WHERE " & _ "luIndustry.ID = " & to_sql(ID,"number") & "" on error resume next set rs = cn.Execute(sql) if err.number <> 0 then b_error = true elseif rs.EOF then b_results = false else ID = rs("ID") Industry = rs("Industry") end if rs.Close on error goto 0 end sub sub db_insert_edit_luIndustry sql = "INSERT INTO luIndustry" & _ "(" & _ "Industry" & _ ") VALUES (" & to_sql(Industry,"text") & ")" & _ "" 'response.write sql on error resume next cn.Execute(sql) if err.Number <> 0 then b_error = true else set rs = cn.Execute("SELECT @@IDENTITY") ID = rs(0) rs.Close end if on error goto 0 end sub sub db_update_edit_luIndustry sql = "UPDATE luIndustry SET " & _ "Industry = " & to_sql(Industry,"text") & " WHERE " & _ "ID = " & to_sql(ID,"number") & "" 'response.write sql on error resume next cn.execute(sql) if err.number <> 0 then b_error = true end if on error goto 0 end sub sub db_delete_edit_luIndustry sql = "DELETE FROM luIndustry" & _ " WHERE " & _ "ID = " & to_sql(ID,"number") & "" 'response.write sql on error resume next cn.Execute(sql) if err.number <> 0 then b_error = true end if on error goto 0 end sub sub db_select_view_luIndustry view_luIndustry_sql = "SELECT " & _ "ID, " & _ "Industry FROM luIndustry" & _ "" if request("sortby") <> "" AND inStr(lcase(view_luIndustry_sql),"order by") = 0 then view_luIndustry_sql = view_luIndustry_sql + " ORDER BY " & request("sortby") end sub sub db_update_view_luIndustry sql = "UPDATE SET " & _ "Industry = " & to_sql(Industry,"text") & "" 'response.write sql on error resume next cn.execute(sql) if err.number <> 0 then b_error = true end if on error goto 0 end sub sub db_delete_view_luIndustry sql = "DELETE FROM " & _ "" 'response.write sql on error resume next cn.Execute(sql) if err.number <> 0 then b_error = true end if on error goto 0 end sub do_search = request("do_search") ''' request form keys ID = request("ID") ''' request action action = lcase(request("action")) ''' action case handler select case action case "select_edit_luindustry" ' select the requested key record from database if ID <> "" then db_select_edit_luIndustry else b_error = true error_list.add "edit_edit_luIndustry", "Specify record to select." end if case "insert_edit_luindustry" ' request form data and insert a new record into database validate_edit_luindustry if not b_error then db_insert_edit_luindustry end if case "update_edit_luindustry" ' request form data and update an existing database record validate_edit_luindustry if not b_error then if ID <> "" then db_update_edit_luindustry else b_error = true error_list.add "update_edit_luindustry", "Specify record to update." end if end if case "delete_edit_luindustry" ' delete the requested key database record if ID <> "" then db_delete_edit_luindustry response.redirect request.servervariables("script_name") & "?msg=The+record+was+deleted." else b_error = true error_list.add "delete_edit_luindustry", "Specify record to delete." end if case "update_view_luindustry"' request form data from edit grid to update existing database records ' this case is only created when a grid form's 'update' property is enabled validate_view_luindustry if not b_error then if then db_update_view_luindustry else b_error = true error_list.add "update_view_luindustry", "Specify record to update." end if end if case "delete_view_luindustry"' request form data from edit grid to delete existing database records ' this case is only created when a grid form's 'update' property is enabled if then db_delete_view_luindustry response.redirect request.servervariables("script_name") & "?msg=The+record+was+deleted." else b_error = true error_list.add "delete_view_luindustry", "Specify record to delete." end if end select ' no action was specified, so handle the default case(s) if ID <> "" then db_select_edit_luindustry end if db_select_view_luindustry %> This table might be useful for associating users and industries. <P><br> <% display_errs display_msg %> <table class='headerTable'> <tr> <td class='headerTD'> Industries Lookup </td> </tr> </table> <table > <form name="edit_luIndustry" action="luIndustry.asp" method="GET" > <tr> <td class='fieldTD'><a href="<% =request.servervariables("script_name") %>?<% =request_string %>page_no=<% =page_no %>&sortby=Industry" class=fieldFont title="">Industry</a></td> </tr> <input type=hidden name="ID" value="<% =ID %>"> <tr> <td class='dataTD' > <input type=text name="Industry" size="" maxlength="50" value="<% =Industry%>"> </td> </tr> <tr> <td align=right class=dataTD colspan=2> <% if ID = "" then %><input type=submit name=insert_button value=insert> <% end if %> <% if ID <> "" then %><input type=submit name=delete_button value=delete onclick="document.edit_luIndustry.action.value = 'delete_edit_luIndustry'"> <% end if %> <% if ID <> "" then %><input type=submit name=update_button value=update><% end if %> </td> <input type=hidden name="action" value="<% if ID <> "" then %>update<% else %>insert<%end if %>_edit_luIndustry"></tr> </form> </table> <% page_no = request("page_no") if page_no = "" then page_no = 1 if view_luIndustry_sql <> "" then cmd.CommandText = view_luIndustry_sql rs.Filter = "" rs.CursorLocation = 3 rs.CacheSize = 5 rs.Open cmd if not rs.EOF then rs.MoveFirst max_count = cInt(rs.PageCount) num_recs = rs.RecordCount rs.AbsolutePage = page_no results = true else results = false rs.Close end if else results = false end if rec_count = 0 %> <table class='headerTable'> <tr> <td class='headerTD'> luIndustry </td> </tr> </table> <% if results = true then %> <table > <form name="view_luIndustry" action="luIndustry.asp" method="GET" > <tr> <td class='fieldTD'><a href="<% =request.servervariables("script_name") %>?<% =request_string %>page_no=<% =page_no %>&sortby=ID" class=fieldFont title="">ID</a></td> <td class='fieldTD'><a href="<% =request.servervariables("script_name") %>?<% =request_string %>page_no=<% =page_no %>&sortby=Industry" class=fieldFont title="">Industry</a></td> </tr> <% do while not rs.EOF ':: read db record on error resume next ID = rs("ID") Industry = rs("Industry") on error goto 0 %> <tr> <td class='dataTD' > <a href="luIndustry.asp?ID=<%=ID%>"><% =ID %></a> </td> <td class='dataTD' > <input type=text name="Industry" size="" maxlength="50" value="<% =Industry%>"> </td> </tr> <% rs.MoveNext rec_count = rec_count + 1 loop rs.Close %> <tr class=formtr> <td class=dataTD align=right colspan=2> <input type=submit name=update_button value=update> </td> </tr> <input type=hidden name="action" value="update_view_luindustry"> </form> </table> <% else %> <% end if %> <% ':: assure that any db resources are freed on error resume next rs.Close set rs = NOTHING cn.Close set cn = NOTHING user_cn.Close set user_cn = NOTHING on error goto 0 %>